const axios = require("axios");
const { apiHost } = require("../config");
/**
 * 响应 GET 请求（响应微信配置时的签名检查请求）
 */
async function list(ctx, next) {
  const data = [
    {
      businessId: 4036,
      dateAdd: "2017-09-15 08:29:50",
      dateUpdate: "2017-09-20 21:14:36",
      id: 1148,
      linkUrl: "",
      paixu: 0,
      picUrl: "https://cdn.it120.cc/apifactory/2017/09/15/145c582252a7a20f21ad9a025ae8c9be.png",
      remark: "",
      status: 0,
      statusStr: "显示",
      title: "1",
      type: "1",
      userId: 951
    },
    {
      businessId: 0,
      dateAdd: "2017-09-15 08:37:04",
      dateUpdate: "2017-09-15 08:37:25",
      id: 1150,
      linkUrl: "",
      paixu: 2,
      picUrl: "https://cdn.it120.cc/apifactory/2017/09/15/73560c511f554eb4afd1dcade9d8ef67.png",
      remark: "",
      status: 0,
      statusStr: "显示",
      title: "3",
      type: "1",
      userId: 951
    },
    {
      businessId: 3776,
      dateAdd: "2017-09-15 08:34:33",
      dateUpdate: "2017-09-20 21:15:54",
      id: 1149,
      linkUrl: "",
      paixu: 3,
      picUrl: "https://cdn.it120.cc/apifactory/2017/09/15/5acdd8f65ec85b413ee642dda795d835.png",
      remark: "",
      status: 0,
      statusStr: "显示",
      title: "2",
      type: "1",
      userId: 951
    }
  ];
  ctx.body = data;
}

async function findById(ctx, next) {
  // 检查签名，确认是微信发出的请求
  const { id } = ctx.params;
  //const { data } = await axios.get(apiHost + "/topics/" + id);
  const data = {
    businessId: 3776,
    dateAdd: "2017-09-15 08:34:33",
    dateUpdate: "2017-09-20 21:15:54",
    id: 1149,
    linkUrl: "",
    paixu: 3,
    picUrl: "https://cdn.it120.cc/apifactory/2017/09/15/5acdd8f65ec85b413ee642dda795d835.png",
    remark: "",
    status: 0,
    statusStr: "显示",
    title: "2",
    type: "1",
    userId: 951
  }
  ctx.body = data;
}

module.exports = {
  findById,
  list
};
